package scoutobahn.highway;

import java.util.Collection;
import java.util.LinkedList;

import scoutobahn.xml.OsmNode;
/**
 * A HighwayNode, a HighwayNode represents a single point
 * in the HighwayGraph network.
 * @author mark
 *
 */
public class HighwayNode extends HighwayElement {
    private boolean marked;
    private final OsmNode node;
    /**
     * Constructs a new HighwayNode from the given OsmNode
     * and with the given parents.
     * @param belongsTo The parent HighwayElement this node belongs to
     * @param osmNode The OsmNode
     */
    public HighwayNode(final Collection<HighwayElement> belongsTo,
            final OsmNode osmNode) {
        super(osmNode, belongsTo);
        this.node = osmNode;
    }
    @Override
    public OsmNode getOsmItem() {
        return this.node;
    }
    /**
     * Returns a collection of the parents that are instances
     * of the Highway class.
     * @return A collection of Highway
     */
    public Collection<Highway> getHighwayParents() {
        LinkedList<Highway> highways = new LinkedList<Highway>();
        for (HighwayElement element : super.getParents()) {
            if (element instanceof Highway) {
                highways.add((Highway) element);
            }
        }
        return highways;
    }
    /**
     * Set's the marked attribute of this node.
     * @param newMarked The new boolean value
     */
    public void setMarked(final boolean newMarked) {
        this.marked = newMarked;
    }
    /**
     * Returns weather this node is marked.
     * @return True when this node is marked
     */
    public boolean isMarked() {
        return marked;
    }
}
